package la.bbs558.strategy.send;

import cn.hutool.captcha.CaptchaUtil;
import cn.hutool.captcha.LineCaptcha;
import la.bbs558.entity.enums.CaptchaTypeEnum;
import la.bbs558.strategy.base.StrategyEnum;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

/**
 * @author: Shanks
 * @date: 2024/1/25 14:18
 * @desc:
 */
@Slf4j
@Component
public class GraphSendStrategy extends AbstractSendStrategy {
    @Override
    public StrategyEnum getStrategyEnum() {
        return CaptchaTypeEnum.GRAPH;
    }

    @Override
    protected void doHandle(SendContext context) {
        //定义图形验证码的长和宽
        LineCaptcha lineCaptcha = CaptchaUtil.createLineCaptcha(200, 100, 4, 0);
        context.setResult(lineCaptcha);
        context.setCode(lineCaptcha.getCode());
    }


}
